package kr.or.kead.ui;

import java.awt.BorderLayout;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.SwingConstants;
import javax.swing.border.EmptyBorder;

import kr.or.kead.ui.insert_update.ProfessorUpdate;
import kr.or.kead.ui.insert_update.StdInsertUpdate;
import java.awt.Color;

public class LevelCheck extends JDialog implements ActionListener {

	private final JPanel contentPanel = new JPanel();
	private JRadioButton radiostd;
	private JRadioButton radioprof;
	private JRadioButton radiodep;
	private JButton okButton;
	private ButtonGroup radio;
	private JButton cancelButton;

	public LevelCheck() {
		setBounds(100, 100, 450, 131);
		getContentPane().setLayout(new BorderLayout());
		contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
		getContentPane().add(contentPanel, BorderLayout.CENTER);
		contentPanel.setLayout(new GridLayout(0, 3, 0, 0));
		{
			radio = new ButtonGroup();
			radiostd = new JRadioButton("학생");
			radiostd.setBackground(Color.CYAN);
			radiostd.setFont(new Font("Rix계란후라이 M", Font.BOLD, 20));
			radiostd.setHorizontalAlignment(SwingConstants.CENTER);
			radio.add(radiostd);
			contentPanel.add(radiostd);
		}
		{
			radioprof = new JRadioButton("교사");
			radioprof.setBackground(Color.GREEN);
			radioprof.setFont(new Font("Rix계란후라이 M", Font.BOLD, 20));
			radioprof.setHorizontalAlignment(SwingConstants.CENTER);
			radio.add(radioprof);
			contentPanel.add(radioprof);
		}
		{
			radiodep = new JRadioButton("직원");
			radiodep.setBackground(Color.YELLOW);
			radiodep.setFont(new Font("Rix계란후라이 M", Font.BOLD, 20));
			radiodep.setHorizontalAlignment(SwingConstants.CENTER);
			radio.add(radiodep);
			contentPanel.add(radiodep);
		}
		{
			JPanel buttonPane = new JPanel();
			getContentPane().add(buttonPane, BorderLayout.SOUTH);
			buttonPane.setLayout(new GridLayout(1, 2, 0, 0));
			{
				okButton = new JButton("OK");
				okButton.addActionListener(this);
				okButton.setActionCommand("OK");
				buttonPane.add(okButton);
				getRootPane().setDefaultButton(okButton);
			}
			{
				cancelButton = new JButton("Cancel");
				cancelButton.addActionListener(this);
				cancelButton.setActionCommand("Cancel");
				buttonPane.add(cancelButton);
			}
		}
		setVisible(true);
	}

	public void actionPerformed(ActionEvent arg0) {
		if (arg0.getSource() == cancelButton) {
			cancelButtonActionPerformed(arg0);
		}
		if (arg0.getSource() == okButton) {
			okButtonActionPerformed(arg0);
		}
	}
	
	protected void okButtonActionPerformed(ActionEvent arg0) {
		if(radiostd.isSelected()) {
			StdInsertUpdate stdinsert = new StdInsertUpdate(null);
			stdinsert.setVisible(true);
		}else if(radioprof.isSelected()){
			ProfessorUpdate profinsert = new ProfessorUpdate(null);
			profinsert.setVisible(true);
		}else{
			JOptionPane.showMessageDialog(null, "공사중입니다!!!메롱");
		}
	}
	
	protected void cancelButtonActionPerformed(ActionEvent arg0) {
		dispose();
	}
}
